package day03;

import java.util.Scanner;

public class Demo03 {
    public static void main(String[] args) {
        //找出数组的最值
        int[] nums = new int[10];
        Scanner sc = new Scanner(System.in);
        for (int i = 0; i < nums.length; i++) {
            int c = i + 1;
            System.out.println("请输入第" + c + "个值:");
            int b = sc.nextInt();
            nums[i] = b;
        }
        for (int i = 0; i < nums.length; i++) {
            System.out.print(nums[i] + " ");
        }
        System.out.println();//遍历输出
        //冒泡排序
        for (int i = 0; i < nums.length - 1; i++) {
            for (int j = 0; j < nums.length - i - 1; j++) {
                if (nums[j] < nums[j + 1]) {
                    int t;//定义一个第三变量，互换值
                    t = nums[j];
                    nums[j] = nums[j + 1];
                    nums[j + 1] = t;
                }
            }
        }
        for (int i = 0; i < nums.length; i++) {
            System.out.print(nums[i] + " ");
        }
        System.out.println();//排序后输出
        System.out.println("最小值为：" + nums[nums.length - 1]);
        System.out.println("最大值为：" + nums[0]);
    }
}
